// @ts-ignore
/* eslint-disable */
import { request } from '@umijs/max';
import { AxiosResponse } from 'axios';

/** 通用对话 POST /conversation/chat */
export async function chat(
  params: API.chatParams,
): Promise<Response> {
  const url = new URL('/api/conversation/chat', window.location.origin);

  // 将 params 转换为 query 参数
  Object.entries(params).forEach(([key, value]) => {
    if (value !== undefined) {
      url.searchParams.append(key, String(value));
    }
  });

  const response = await fetch(url.toString(), {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify(params),
    credentials: 'include', // 如果需要携带 cookie
  });

  return response;
}

/** 创建对话 GET /conversation/chat/create */
export async function create(options?: { [key: string]: any }) {
  return request<API.CommonResultConversationVO>('/api/conversation/chat/create', {
    method: 'GET',
    ...(options || {}),
  });
}

/** 删除对话 DELETE /conversation/chat/del */
export async function del(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.delParams,
  options?: { [key: string]: any },
) {
  return request<API.CommonResultBoolean>('/api/conversation/chat/del', {
    method: 'DELETE',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** 修改对话 PUT /conversation/chat/edit */
export async function edit(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.editParams,
  options?: { [key: string]: any },
) {
  return request<API.CommonResultBoolean>('/api/conversation/chat/edit', {
    method: 'PUT',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** 获取对话 GET /conversation/chat/get */
export async function get(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.getParams,
  options?: { [key: string]: any },
) {
  return request<API.CommonResultConversationVO>('/api/conversation/chat/get', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** 展示对话 GET /conversation/chat/list */
export async function list(options?: { [key: string]: any }) {
  return request<API.CommonResultListConversationVO>('/api/conversation/chat/list', {
    method: 'GET',
    ...(options || {}),
  });
}

/** 深度对话 POST /conversation/deepChat */
export async function deepChat(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.deepChatParams,
  options?: { [key: string]: any },
) {
  return request<string[]>('/conversation/deepChat', {
    method: 'POST',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** 混合检索 GET /conversation/search */
export async function search(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.searchParams,
  options?: { [key: string]: any },
) {
  return request<API.CommonResultString>('/conversation/search', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}
